package com.rpframework.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

import org.apache.commons.lang.StringUtils;


/**
 *  日期帮助类
 * @author rplees
 * @date 2010-10-18
 */
public class DateUtils {
	
	public final static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public final static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public final static String DEFAULT_DATE_FORMAT = YYYY_MM_DD_HH_MM_SS;
	public final static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
	public final static String YYYY_MM_DD = "yyyy-MM-dd";
	public final static String YYYYMMDD = "yyyyMMdd";
	
	private static Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("ETC/GMT-8"), Locale.CHINESE);
	
	/**
	 * 获取系统当前时间
	 * @param dataFormat 返回的时间格式
	 * @return
	 */
	public static String getSystemTime(String dateFormat){
		Date date=new Date();
		DateFormat df=new SimpleDateFormat(dateFormat);
		return df.format(date);
	}
	
	/**
	 * 将时间戳转为格式化时间
	 * @param date 时间戳
	 * @param formart 格式
	 * @return
	 */
	public static String formartDate(Long date , String formart){
		DateFormat df=new SimpleDateFormat(formart);
		return df.format(date*1000);
	}
	
	/**
	 * 判断是否是闰年
	 * @param int year 年
	 * @return boolean true:闰年
	 */
	public boolean isLeapYear(int year) {
		if ((year % 400) == 0)
			return true;
		else if ((year % 4) == 0) {
			if ((year % 100) == 0)
				return false;
			else
				return true;
		} else
			return false;
	}
	
	/**
	 * 判断星座
	 * @param month
	 * @param day
	 * @return
	 */
	public static String getConstellation(int month,int day){  
		final String[] constellationArr = {"魔羯座" ,"水瓶座", "双鱼座", "牡羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座","天蝎座", "射手座", "魔羯座" };   
		final int[] constellationEdgeDay = { 20,18,20,20,20,21,22,22,22,22,21,21};  
		if (day <= constellationEdgeDay[month-1]) {     
			month = month - 1;     
		}     
        if (month >= 0) {     
            return constellationArr[month];     
        }     
	    return constellationArr[11];     
    }
	
	/**
	 * 输入 时间，得出星期几
	 * @param sdate yyyy-MM-dd 
	 * @return 1=星期日 7=星期六，其他类推
	 */
	public static String getWeek(String sdate) {
		Date date = strToDate(sdate);
		calendar.setTime(date);
		return new SimpleDateFormat("EEEE").format(calendar.getTime());
	}
	public static Date strToDate(String strDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(strDate, pos);
		return strtodate;
	}

	public static int getDayOfWeek(){
		Calendar cal = Calendar.getInstance();
		int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
		return dayOfWeek;
	}
	

	/**
	 * 根据两个时间搓计算年龄
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static int getAge(Long date1, Long date2){
		Long age = (date1 - date2) / 365 / ((3600 * 24) );
		return age.intValue();
	}
	
	/**
	 * 计算过去时间，将date与当前系统时间进行对比
	 * @param date 要进行比较的时间，
	 * @return 字符串
	 */
	public static String pastTime(Date date) {
		int second = secondBetween(date);
		if (second<60) {
			return second+"秒前";
		} else if (second>60 && second < 30*60) {
			return (second/60)+"分钟前";
		} else if (second>30*60 && second < 60*60) {
			return "半小时前";
		} else if (second>60*60 && second < 24*60*60) {
			return (second/60/60)+"小时前";
		} else if (second>24*60*60 && second < 24*30*60*60) {
			return (second/60/60/24)+"天前";
		}  else if (second>24*30*60*60 && second < 24*30*12*60*60) {
			return (second/60/60/24/30)+"月前";
		} else {
			return DateUtils.dateFmtToString(date,"yyyy-MM-dd HH:mm:ss");
		}
	}
	
	/**
	 * 在指定时间的基础上增加 days 后的日期
	 * @param days 添加的时间
	 * @param date 指定的时间 yyyy-MM-dd
	 * @return
	 */
	public static String dayAdd(int days, String date) {
		try {
			return getDateFormat().format(DateUtils.dayAdd(days, parse(date))) ;
		} catch (Exception e) {
			return null;
		}
	}
	/** 
	* 获得指定日期的前一天 
	* @param specifiedDay 
	* @return 
	* @throws Exception 
	*/ 
	public static String getSpecifiedDayBefore(String specifiedDay,int nums){ 
	//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
	Calendar c = Calendar.getInstance(); 
	Date date=null; 
	try { 
	date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay); 
	} catch (ParseException e) { 
	e.printStackTrace(); 
	} 
	c.setTime(date); 
	int day=c.get(Calendar.DATE); 
	c.set(Calendar.DATE,day-nums); 

	String dayBefore=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); 
	return dayBefore; 
	} 
	/**
	 * 计算两个时间间隔天数
	 * 
	 * @param startday
	 * @param endday
	 * @return
	 */
	public static int getDaysBetween(Calendar d1, Calendar d2) {
		if (d1.after(d2)) {
			java.util.Calendar swap = d1;
			d1 = d2;
			d2 = swap;
		}
		int days = d2.get(Calendar.DAY_OF_YEAR) - d1.get(Calendar.DAY_OF_YEAR);
		int y2 = d2.get(Calendar.YEAR);
		if (d1.get(Calendar.YEAR) != y2) {
			d1 = (Calendar) d1.clone();
			do {
				days += d1.getActualMaximum(Calendar.DAY_OF_YEAR);// 得到当年的实际天数
				d1.add(Calendar.YEAR, 1);
			} while (d1.get(Calendar.YEAR) != y2);
		}
		return days;
	}

	
	/**
	 * 指定时间增加月份
	 * @param t 时间
	 * @param month 月份
	 * @return
	 */
	public static Date addMonths(Date t, int month) {
		if (t == null)
			return null;
		Calendar c = Calendar.getInstance();
		c.setTime(t);
		c.set(Calendar.MONTH, c.get(Calendar.MONTH) + month);
		return c.getTime();
	}
	
	/**  
	 * 是否为同一个月份
	 * @param d1
	 * @param d2
	 * @return  Boolean.True 同一个
	 */
	public static boolean isSameMonth(Date d1, Date d2) {
		Calendar instance = Calendar.getInstance();
		instance.setTime(d1);
		int i1 = instance.get(Calendar.MONTH);
		
		instance.setTime(d2);
		int i2 = instance.get(Calendar.MONTH);
		
		return i1 == i2;
	}
	
	/**  
	 * 是否为同一个天数
	 * @param d1
	 * @param d2
	 * @return  Boolean.True 同一个
	 */
	public static boolean isSameDay(Date d1, Date d2) {
		Calendar instance = Calendar.getInstance();
		instance.setTime(d1);
		int i1 = instance.get(Calendar.DAY_OF_YEAR);
		
		instance.setTime(d2);
		int i2 = instance.get(Calendar.DAY_OF_YEAR);
		
		return i1 == i2;
	}
	
	/**
	 * 计算系统当前时间和传入时间相差的时间(精确到秒)
	 * 如果结果大于零则当前系统时间大于传入的时间，小于零则相反
	 * @param date 传入的时间
	 * @return 相差的时间
	 */
	public static int secondBetween(Date date){
		if (date==null) {
			return 0;
		}
		SimpleDateFormat sdfSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			long presentDate = sdfSecond.parse(sdfSecond.format(new Date())).getTime();
			long enterDate =  date.getTime();
			return (int) ((presentDate-enterDate)/1000);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return 1;
	}

	public static String dateFmtToString(Date date, String fmt) {
		return new SimpleDateFormat(fmt).format(date);
	}
	
	/**
	 * 判断两个时间是否有交集
	 * @param start1
	 * @param end1
	 * @param start2
	 * @param end2
	 * @return
	 */
	public boolean hasCommon(Date start1 , Date end1 ,Date start2 , Date end2){
		if(end1.before(start2)||end2.before(start1))
			return false;
		else
			return true;
	}
	/** 
	  * 获得周日的日期 
	  * 
	  * @param date 
	  * @return 
	  */ 
	public static String getSunday(Date date) {

		DateFormat df=new SimpleDateFormat(YYYY_MM_DD);
	  Calendar calendar = Calendar.getInstance();

	  calendar.setTime(date);

	  calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);

	  return df.format(calendar.getTime());

	} 
	    /** 
	  * 获得周六的日期 
	  * 
	  * @param date 
	  * @return 
	  */ 
	public static String getSaturday(Date date) {

		DateFormat df=new SimpleDateFormat(YYYY_MM_DD);
	  Calendar calendar = Calendar.getInstance();

	  calendar.setTime(date);

	  calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

	  return df.format(calendar.getTime()); 
	}
	/**
	 * 将开始时间与结束时间转换成时间格式,eg:2015-4-5至2015-3-2
	 * @param date 2015-4-5至2015-3-2
	 * @param split 至
	 * @param fmt 格式
	 * @return 转换失败null
	 */
	public static Date[] beginEndStringToDate(String date,String split,String fmt) {
		if (StringUtils.isBlank(date) || StringUtils.isBlank(split)) {
			return null;
		}
		String[] _date = date.split(split);
		if (_date.length==2) {
			Date[] d = new Date[2];
			d[0] = DateUtils.stringFmtToDate(_date[0], fmt);
			d[1] = DateUtils.stringFmtToDate(_date[1], fmt);
			return d;
		}
		return null;
	}
	
	/**
	 * 将date转换为日历
	 * @param date　时间
	 * @return Calendarl类型
	 */
	public static Calendar date2Calendar(Date date) {
		Calendar calendar = Calendar.getInstance(); //得到日历
		 calendar.setTime(date);
		return calendar;
	}
	
	public static boolean judgeDateMsg(String date){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");// 日期格式化
		try{
			java.sql.Date.valueOf(df.format(java.sql.Date.valueOf(date)));
		}catch (NumberFormatException e){
			return false;
		}
		return true;
	}
	
	/**
	 * 字符串转日期，可以按一定格式
	 * @param String date 日期字符串<br>
	 * @param String dataFmt 格式化后的日期<br>
	 * @return Date
	 */
	public static Date stringFmtToDate(String date, String dataFmt) {
		SimpleDateFormat df = new SimpleDateFormat(dataFmt);
		return java.sql.Date.valueOf(df.format(java.sql.Date.valueOf(date)));
	}
	

	
	
	/**
	 * 将string 格式字符串转换成long型
	 */
	public static Long verifyDateformString(String s ) throws ParseException{
	   return getDateFormat(YYYY_MM_DD_HH_MM_SS).parse(s).getTime();
	}
	
	public static Date getTodayStartDate() {
		return getDayStartDate(new Date());
	}
	
	public static Date getDayStartDate(Date date) {
		Calendar currentDate = new GregorianCalendar();   
		currentDate.setTime(date);
		
		currentDate.set(Calendar.HOUR_OF_DAY, 0);  
		currentDate.set(Calendar.MINUTE, 0);  
		currentDate.set(Calendar.SECOND, 0);  
		currentDate.set(Calendar.MILLISECOND, 0);
		return currentDate.getTime();
	}
	
	public static Date getDayEndDate(Date date) {
		Calendar currentDate = new GregorianCalendar();   
		currentDate.setTime(date);
		
		currentDate.set(Calendar.HOUR_OF_DAY, 24);  
		currentDate.set(Calendar.MINUTE, 0);  
		currentDate.set(Calendar.SECOND, 0);
		currentDate.set(Calendar.MILLISECOND, 0);
		return currentDate.getTime();
	}
	
	public static Date getTodayEndDate() {
		return getDayEndDate(new Date());
	}
	
	
	public static Date getWeekStartDate() {
		Calendar cal = Calendar.getInstance();
		cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
		cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		return  cal.getTime();
	}
	
	public static Date getWeekEndDate() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(getWeekStartDate());
		cal.add(Calendar.DAY_OF_WEEK, 7);
		return cal.getTime();
	}
	
	public static Date getMonthStartDate() {
		Calendar cal = Calendar.getInstance();
		cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
		cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
		return  cal.getTime();
	}
	
	public static Date getMonthEndDate() {
		Calendar cal = Calendar.getInstance();
		cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
		cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
		cal.set(Calendar.HOUR_OF_DAY, 24);
		return cal.getTime();
	}
	
	/**
	 * 验证是不是有效的日期
	 * @param dys
	 * @param hrs
	 * @return
	 */
	public static boolean verifyDateRule(DayRule dr, DateRule ... hrs) {
		DayRule[] drs = new DayRule[1];
		drs[0] = dr;
		
		return verifyDateRule(drs, hrs);
	}
	
	/**
	 * 验证是不是有效的日期
	 * @param dys
	 * @param hrs
	 * @return
	 */
	public static boolean verifyDateRule(DayRule dr) {
		DayRule[] drs = new DayRule[1];
		drs[0] = dr;
		
		return verifyDateRule(drs, null);
	}
	
	/**
	 * 验证是不是有效的日期
	 * @param dys
	 * @param hrs
	 * @return
	 */
	public static boolean verifyDateRule(DayRule[] dys, DateRule ... hrs) {
		Date d = new Date();
		
		boolean f = false;
		if(dys != null && dys.length > 0) {
			for (DayRule dr : dys) {
				if(dr.between(d)) f = true;
				if(f) break;
			}
		} else {
			f = true;
		}
		
		//天数验证不通过，就没必要验证小时了
		if(! f) return f;
		
		if(hrs == null || hrs.length < 1) return true;
		for (DateRule hr : hrs) {
			if(hr.between(d)) return true;
		}
		
		return false;
	}
	
	/**
	 * 在现在时间的基础上增加 days 后的日期
	 * @param days
	 * @return
	 */
	public static Date dayAdd(int days) {
        Calendar calendar = Calendar.getInstance();
        int day = calendar.get(Calendar.DAY_OF_YEAR);
        calendar.set(Calendar.DAY_OF_YEAR, day + days);
        return calendar.getTime();
    }
	/**
	 * 在指定时间的基础上增加 hour 后的日期
	 * @param hour
	 * @return
	 */
	public static Date hourAdd(int hour, Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int hours = calendar.get(Calendar.HOUR_OF_DAY);
		calendar.set(Calendar.HOUR_OF_DAY, hours + hour);
		return calendar.getTime();
	}
	/**
	 * 在现在时间的基础上增加 days 后的日期
	 * @param days
	 * @return
	 */
	public static Date hourAdd(int hour) {
		Calendar calendar = Calendar.getInstance();
		int hours = calendar.get(Calendar.HOUR_OF_DAY);
		calendar.set(Calendar.HOUR_OF_DAY, hours + hour);
		return calendar.getTime();
	}
	/**
	 * 在指定时间的基础上增加 days 后的日期
	 * @param days
	 * @return
	 */
	public static Date dayAdd(int days, Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int day = calendar.get(Calendar.DAY_OF_YEAR);
		calendar.set(Calendar.DAY_OF_YEAR, day + days);
		return calendar.getTime();
	}
	
	
    public static Date parse(String date) {
    	try {
    		return getDateFormat().parse(date);
		} catch (Exception e) {
			try {
	    		return getDateFormat(YYYY_MM_DD_HH_MM_SS).parse(date);
			} catch (Exception e1) {
				try {
					return getDateFormat(YYYY_MM_DD_HH_MM).parse(date);
				} catch (ParseException e2) {
					try {
			    		return getDateFormat(YYYYMMDDHHMMSS).parse(date);
					} catch (Exception e3) {
						try {
				    		return getDateFormat(YYYY_MM_DD).parse(date);
						} catch (Exception e4) {
							return null;
						}
					}
				}
			}
		}
	}
    
    public static int getNowDayOfWeek() {
    	return getDayOfWeek(new Date());
    }
    /**  
     * 描述
     * @param dt
     * @return  0 - 礼拜7
     */
    public static int getDayOfWeek(Date dt) {
    	Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        return w;
    }
	//月数操作
    public static Date monthAdd(int months) {
	    Calendar calendar = Calendar.getInstance();
	    int m = calendar.get(Calendar.MONTH);
	    calendar.set(Calendar.MONTH, m + months );
	    return calendar.getTime();
	}
    
    //月数操作
    public static Date monthAdd(int months, Date date) {
	    Calendar calendar = Calendar.getInstance();
	    calendar.setTime(date);
	    int m = calendar.get(Calendar.MONTH);
	    calendar.set(Calendar.MONTH, m + months );
	    return calendar.getTime();
	}
    
	public static Date minAdd(int mins) {
		Calendar calendar = Calendar.getInstance();
		int day = calendar.get(12);
		calendar.set(12, day + mins);
		return calendar.getTime();
	}

	public static Date minAdd(int hour, Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		int hours = calendar.get(12);
		calendar.set(12, hours + hour);
		return calendar.getTime();
	}

    /**
     * 根据DateFormat 格式化现在时间
     * @param df 
     * @return 如:2012-12-21
     */
    public static String nowDate(DateFormat df){
		if (null == df) {
			df = getDateFormat();
		}
		return df.format(new Date());
    }
    /**
     * 默认的格式化时间
     * @return 2012-12-21 12:31:20
     */
    public static String nowDate(){
    	return getDateFormat().format(new Date());
    }
    /**
     * 默认的格式化时间
     * @return 2012-12-21 12:31:20
     */
    public static String nowDate(String format){
    	return getDateFormat(format).format(new Date());
    }
    
    public static DateFormat getDateFormat(){
    	return new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    }
    
    public static DateFormat getDateFormat(String format){
    	return new SimpleDateFormat(format);
    }
	public static String format(String format, Date date) {
		return getDateFormat(format).format(date);
	}
	public static String getWeekOfDate(Long l) {
		Date dt = new Date(l);
	    String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
	    Calendar cal = Calendar.getInstance();
	    cal.setTime(dt);
	    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
	    if (w < 0)
	        w = 0;
	    return weekDays[w];
	}
	
	// 获得当天0点时间
		public static Date getTimesmorning() {
			Calendar cal = Calendar.getInstance();
			cal.set(Calendar.HOUR_OF_DAY, 0);
			cal.set(Calendar.SECOND, 0);
			cal.set(Calendar.MINUTE, 0);
			cal.set(Calendar.MILLISECOND, 0);
			return cal.getTime();
		}
		/**
		 * 获取当天0点时间戳
		 * @return
		 * @throws ParseException
		 */
		public static Long getMorningLong() throws ParseException {
			String fmtDate = DateUtils.dateFmtToString(getTimesmorning(), "yyyy-MM-dd HH:mm:ss");
			Long longDate = verifyDateformString(fmtDate);
			return longDate/1000;
		}
		// 获得当天24点时间
		public static Date getTimesnight() {
			Calendar cal = Calendar.getInstance();
			cal.set(Calendar.HOUR_OF_DAY, 24);
			cal.set(Calendar.SECOND, 0);
			cal.set(Calendar.MINUTE, 0);
			cal.set(Calendar.MILLISECOND, 0);
			return cal.getTime();
		}
		/**
		 * 获取当天24点时间戳
		 * @return
		 * @throws ParseException
		 */
		public static Long getNightLong() throws ParseException {
			String fmtDate = DateUtils.dateFmtToString(getTimesnight(), "yyyy-MM-dd HH:mm:ss");
			Long longDate = verifyDateformString(fmtDate);
			return longDate/1000;
		}
		/**
		 * 获得本周一0点时间
		 * @return
		 */
		public static Date getTimesWeekmorning() {
			Calendar cal = Calendar.getInstance();
			cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
			cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
			return cal.getTime();
		}
		
		// 获得本周日24点时间
		public static Date getTimesWeeknight() {
			Calendar cal = Calendar.getInstance();
			cal.setTime(getTimesWeekmorning());
			cal.add(Calendar.DAY_OF_WEEK, 7);
			return cal.getTime();
		}

		// 获得本月第一天0点时间
		public static Date getTimesMonthmorning() {
			Calendar cal = Calendar.getInstance();
			cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
			cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
			return cal.getTime();
		}
		
		// 获得本月最后一天24点时间
		public static Date getTimesMonthnight() {
			Calendar cal = Calendar.getInstance();
			cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
			cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
			cal.set(Calendar.HOUR_OF_DAY, 24);
			return cal.getTime();
		}
		/**
		 * 	System.out.println("当前时间："+ new Date().toLocaleString());
			System.out.println("当天0点时间："+ getTimesmorning().toLocaleString());
			System.out.println("当天24点时间："+ getTimesnight().toLocaleString());
			System.out.println("本周周一0点时间："+ getTimesWeekmorning().toLocaleString());
			System.out.println("本周周日24点时间："+ getTimesWeeknight().toLocaleString());
			System.out.println("本月初0点时间："+ getTimesMonthmorning().toLocaleString());
			System.out.println("本月未24点时间："+ getTimesMonthnight().toLocaleString());
		 */
		/**
		 * 获取当前周一的毫秒数
		 * @param weekpage 
		 * @return 时间戳
		 * @throws ParseException 
		 */
		public static Long getMonday(Integer weekpage) throws ParseException{
			Date date = DateUtils.getTimesWeekmorning();
			/*格式化为String时间*/
			String fmtDate = DateUtils.dateFmtToString(date, "yyyy-MM-dd HH:mm:ss");
			/*格式化为毫秒数*/
			/*weekpage  能表示上下第几周*/
			fmtDate = dayAdd(weekpage*7, fmtDate);
			Long longDate = DateUtils.verifyDateformString(fmtDate);
			/*返回时间戳*/
			return longDate/1000;
		}
}